<!DOCTYPE html>
<html lang="zh-CN">
<head>
    <meta charset="UTF-8">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <title>游戏测试</title>
    <style>
        body {
            margin: 0;
            padding: 20px;
            background-color: #1a1a1a;
            color: white;
            font-family: Arial, sans-serif;
        }
        #gameCanvas {
            border: 2px solid #333;
            background-color: #000;
        }
        .controls {
            margin-top: 10px;
        }
        button {
            margin: 5px;
            padding: 10px 20px;
            background-color: #4CAF50;
            color: white;
            border: none;
            border-radius: 5px;
            cursor: pointer;
        }
        button:hover {
            background-color: #45a049;
        }
        .status {
            margin-top: 10px;
            padding: 10px;
            background-color: #2a2a2a;
            border-radius: 5px;
        }
    </style>
</head>
<body>
    <h1>武器资源测试</h1>
    <canvas id="gameCanvas" width="800" height="600"></canvas>
    
    <div class="controls">
        <button onclick="addWeapon('knife')">添加飞刀</button>
        <button onclick="addWeapon('fireball')">添加火球</button>
        <button onclick="addWeapon('ice_shard')">添加冰锥</button>
        <button onclick="clearWeapons()">清除武器</button>
    </div>
    
    <div class="status" id="status">准备就绪</div>

    <!-- 游戏脚本 -->
    <script src="js/utils.js"></script>
    <script src="js/balanceConfig.js"></script>
    <script src="js/spriteManager.js"></script>
    <script src="js/sprite.js"></script>
    <script src="js/pixelArt.js"></script>
    <script src="js/uiAssets.js"></script>
    <script src="js/soundGenerator.js"></script>
    <script src="js/performance.js"></script>
    <script src="js/player.js"></script>
    <script src="js/enemy.js"></script>
    <script src="js/weapon.js"></script>
    <script src="js/item.js"></script>
    <script src="js/clone.js"></script>
    <script src="js/minion.js"></script>
    <script src="js/ui.js"></script>
    <script src="js/game.js"></script>

    <script>
        let game;
        let testEnemies = [];
        
        // 初始化测试
        async function initTest() {
            const canvas = document.getElementById('gameCanvas');
            const ctx = canvas.getContext('2d');
            
            // 创建简单的游戏实例
            game = new Game();
            
            // 等待资源加载
            await game.loadGameAssets();
            
            // 创建测试敌人
            createTestEnemies();
            
            // 开始渲染循环
            renderLoop();
            
            updateStatus('游戏已初始化，武器资源加载完成');
        }
        
        function createTestEnemies() {
            testEnemies = [
                { x: 400, y: 300, size: 15, isDead: false },
                { x: 500, y: 200, size: 15, isDead: false },
                { x: 300, y: 400, size: 15, isDead: false }
            ];
        }
        
        function renderLoop() {
            const canvas = document.getElementById('gameCanvas');
            const ctx = canvas.getContext('2d');
            
            // 清空画布
            ctx.fillStyle = '#000000';
            ctx.fillRect(0, 0, canvas.width, canvas.height);
            
            // 渲染玩家
            if (game.player) {
                ctx.fillStyle = '#00FF00';
                ctx.beginPath();
                ctx.arc(game.player.x, game.player.y, game.player.size, 0, Math.PI * 2);
                ctx.fill();
            }
            
            // 渲染敌人
            ctx.fillStyle = '#FF0000';
            testEnemies.forEach(enemy => {
                if (!enemy.isDead) {
                    ctx.beginPath();
                    ctx.arc(enemy.x, enemy.y, enemy.size, 0, Math.PI * 2);
                    ctx.fill();
                }
            });
            
            // 更新和渲染武器
            if (game.weaponManager) {
                game.weaponManager.update(16, testEnemies);
                game.weaponManager.render(ctx);
            }
            
            requestAnimationFrame(renderLoop);
        }
        
        function addWeapon(type) {
            if (game && game.weaponManager) {
                game.weaponManager.addWeapon(type);
                updateStatus(`已添加武器: ${type}`);
            }
        }
        
        function clearWeapons() {
            if (game && game.weaponManager) {
                game.weaponManager.weapons = [];
                updateStatus('已清除所有武器');
            }
        }
        
        function updateStatus(message) {
            document.getElementById('status').textContent = message;
            console.log(message);
        }
        
        // 启动测试
        window.addEventListener('load', initTest);
    </script>
</body>
</html> 